package suncertify.shared;

import java.rmi.Remote;
import java.rmi.RemoteException;

import java.util.ArrayList;

/**
 *
 * @author jshah
 * Interface which creates a wrapper around the low level <code>DBAccess</code> class, This is the interface for the Remote object used
 * in the RMI Server to interact with the database file. The RemoteObject <code>ServerBrokerImplementation</code> implements this methods
 * thus client can make remote calls on any of this methods to interact with the database file remotely.
 */
public interface ServerBroker extends Remote {

   

    /**
     * Overloaded version of setDbPath where no argument for dbfile path is required as the path set by the server in properties file is used
     * @return      returns true if valid dbfile and successful instantiation of <code>DBAccess</code>
     * @throws <code>java.rmi.RemoteException</code>  A remote exception is thrown if not able to bind to the remote object 
     */
    public boolean setDbPath() throws RemoteException;

    /**
      * Function which calls appropriate method in <code>DBAccess</code> to search records from the db file
      * @param name             String representing the desired value of the "Name" field in the records
      * @param Location         String representing the desired value of the "Location" field in the records
      * @return                 returns the list of all the records
     *  @throws RemoteException
      */
    public ArrayList<String[]> searchRecords(String name, String Location) throws RemoteException;

    /**
     * Supplies a customer id String which is "4digit number" to indicate customer currently hiring the contractor
     * @param recNo                      recNo of the record in the dbfile
     * @param customerID                 A four digit customer ID string unique to each custormer(it is assumed that customer provides this to the CSR)
     * @return                           returns a String to notify wether a booking was successful or if not then returns a message corresponding to the ERRORCODE indicating the reason                                      '
     * @throws                           RemoteException
     */
     public String book(int recNo, String customerID) throws RemoteException;

     /**
     * unbooks by clearing the customer id in the owned by column of the record in dbfile
     * @param recNo          record no. of the record which needs to unbooked
     * @return              returns a string message representing wether it was a success or the type of error
     * @throws              RemoteException
     */
    public String unbook(int recNo) throws RemoteException;

     /**
     * Calls the read method of <code>DBAccess</code> to return a <code>String[]</code> containing the contents of record
     * @param recNo         the number of the record whose contents are requested
     * @return              <code>String[]</code> containing the contents of record where each elements represents a field of the record, returns <code>null</code> if record not found
      * @throws             RemoteException
     */
    public String[] read(int recNo) throws RemoteException;
}

